package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Vs;
import com.ruoyi.system.service.IVsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * VSController
 * 
 * @author ruoyi
 * @date 2025-03-23
 */
@RestController
@RequestMapping("/system/vs")
public class VsController extends BaseController
{
    @Autowired
    private IVsService vsService;

    /**
     * 查询VS列表
     */
    @PreAuthorize("@ss.hasPermi('system:vs:list')")
    @GetMapping("/list")
    public TableDataInfo list(Vs vs)
    {
        startPage();
        List<Vs> list = vsService.selectVsList(vs);
        return getDataTable(list);
    }

    /**
     * 导出VS列表
     */
    @PreAuthorize("@ss.hasPermi('system:vs:export')")
    @Log(title = "VS", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Vs vs)
    {
        List<Vs> list = vsService.selectVsList(vs);
        ExcelUtil<Vs> util = new ExcelUtil<Vs>(Vs.class);
        util.exportExcel(response, list, "VS数据");
    }

    /**
     * 获取VS详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:vs:query')")
    @GetMapping(value = "/{boxId}")
    public AjaxResult getInfo(@PathVariable("boxId") Integer boxId)
    {
        return AjaxResult.success(vsService.selectVsByBoxId(boxId));
    }

    /**
     * 新增VS
     */
    @PreAuthorize("@ss.hasPermi('system:vs:add')")
    @Log(title = "VS", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Vs vs)
    {
        return toAjax(vsService.insertVs(vs));
    }

    /**
     * 修改VS
     */
    @PreAuthorize("@ss.hasPermi('system:vs:edit')")
    @Log(title = "VS", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Vs vs)
    {
        return toAjax(vsService.updateVs(vs));
    }

    /**
     * 删除VS
     */
    @PreAuthorize("@ss.hasPermi('system:vs:remove')")
    @Log(title = "VS", businessType = BusinessType.DELETE)
	@DeleteMapping("/{boxIds}")
    public AjaxResult remove(@PathVariable Integer[] boxIds)
    {
        return toAjax(vsService.deleteVsByBoxIds(boxIds));
    }
}
